<?php defined('SYSPATH') or die('No direct script access.');
class registrationUtils {
    public static function canBeCancelled($registration, $seminar, $paymentAcceptance = null) {
        $sessionData = SessionData::instance();
        $account = $sessionData->getAuthUser();

        if ($registration['cancelled_at']) {
            return false;
        }
        
        if ($paymentAcceptance && $paymentAcceptance['confirmed_at']) {
        	return false;
        }

        // Admin can cancel the requisition at any time
        if ($account['is_admin']) {
            return true;
        }
        
        if (date::isInPast($seminar['begin_date'], $seminar['begin_time'])) {
            return false;
        }
        return true;
    }
}